import { get, post, put, del } from '@/utils/request'

// 品牌相关的类型定义
export interface Role {
  id: number
  roleName: string
  IsDeleted?: boolean
}

export interface RoleQueryParams {
  pageNum: number
  pageSize: number
  name?: string
  status?: number
}

export interface RoleResponse {
  totalCount: number
  totalPages: number
  list: Role[]
}

// API 响应类型
export interface ApiResponse<T> {
  code: number
  message: string
  data: T
}

// 创建品牌的参数类型
export interface CreateRoleParams {
  roleName: string
  id?: number
}

// 获取角色列表
export const reqRoleList = () => {
  return get<ApiResponse<Role[]>>('/api/Permissions/GetRolesList')
}

// 添加角色
export const reqCreateRole = (data: CreateRoleParams, ids: string) => {
  return post<ApiResponse<number>>('/api/Permissions/AddRole?ids=' + ids, data)
}

// 删除角色
export const reqDeleteRole = (id: number) => {
  return del<ApiResponse<number>>(`/api/Permissions/DelRole?id=${id}`)
}

// 获取角色权限
export const reqRolePermission = (id: number) => {
  return get<ApiResponse<number>>(
    `/api/Permissions/GetPermissionIdList?roleId=${id}`
  )
}
